#ifndef DYN_QUAD_QROMBERG_H
#define DYN_QUAD_QROMBERG_H

#include <armadillo>

#include "dyn_quad.h"
#include "dyn_trapzDriver.h"
#include "../interpolation/dyn_interpolation_poly.h"

using namespace arma;

/*! \author Joey Dumont
 *
 *  \date 2012-10-05
 *
 *  \brief Implements a general Romberg integration class.
 *
 * Romberg integration is a generalization of the method
 * used in the Simpson case. Given a number of previous
 * results for different stepsizes, we extrapolate
 * the results to zero stepsize.
 */

class qRomberg : public Quad
{
public:
    /*! The constructor defines the basic
     * variables, as well as the number of
     * points used in the polynomial interpolation.
     * The maximum number of iterations is also defined.
     */
    qRomberg(Functor& _func,
             double _a,
             double _b,
             double _tol,
             int _ptsInterpolation,
             int _maxIterations);

    /*! @name Accessor Functions */
    //@{
    int getPtsInterpolation(){return ptsInterpolation;}
    int getMaxIterations(){return maxIterations;}

    void setPtsInterpolation(int _ptsInterpolation){ptsInterpolation=_ptsInterpolation;}
    void setMaxIterations(int _maxIterations){maxIterations=_maxIterations;}
    //@}

    /*! Re-declared pure virtual function. */
    double doQuadrature();

protected:
    /*! Number of points in interpolation. */
    int ptsInterpolation;
    /*! Maximum number of refinements to be used in TrapzDriver. */
    int maxIterations;
};

#endif // DYN_QUAD_QROMBERG_H
